<?php 

$student=array(20120210420235=>array('name'=>'lijian','grade'=>81),
		  20120210420125=>array('name'=>'chengyi','grade'=>90),
		  20120210420219=>array('name'=>'hehsiyang','grade'=>78),
		  20120240420119=>array('name'=>'ousheng','grade'=>68));
 /*function sort_name($x,$y){
 	static $count=1;//设置一个静态变量，记录函数调用的次数；
 	echo "函数被调用了{$count}次:{$x['name']} vs.{$y['name']} <br>";
 	$count++;
 	return strcasecmp($x['name'], $y['name']);
 }*/
 /*function sort_grade($x,$y){
 	static $count=1;
 	echo "函数被调用了{$count}次：{$x['grade']} vs.{$y['grade']}<br>";
 	$count++;
 	return ($x['grade']<$y['grade']);
 }*/
//uasort($student, 'sort_name');
 //使用匿名函数
uasort($student, function($x,$y){
	static $count=1;//设置一个静态变量，记录函数调用的次数；
 	echo "函数被调用了{$count}次:{$x['name']} vs.{$y['name']} <br>";
 	$count++;
 	return strcasecmp($x['name'], $y['name']);
});
echo "<h1>姓名排序结果：</h1>\n";
print_r($student);
//uasort($student, 'sort_grade');
//使用匿名函数
uasort($student, function($x,$y){
	static $count=1;
 	echo "函数被调用了{$count}次：{$x['grade']} vs.{$y['grade']}<br>";
 	$count++;
 	return ($x['grade']<$y['grade']);

});
echo "<h1>分数排序结果：</h1>\n";
print_r($student);
 ?>